export function setCookie(key,value,seconds,path='/'){
    var date = new Date()
    date.setTime(date.getTime()-8*3600*1000+ seconds * 1000)
    document.cookie = key + '=' + value + ';expires=' +date + ';path=' +path
}

export function getCookie(key){
    var cookies = document.cookie   //获取所有cookie,样式为'key=value; key=value; key=value'
    if(!cookies) return
    var arr = cookies.split('; ')
    for(var a = 0;a<arr.length;a++){
        var brr = arr[a].split('=')  //每次都会更新brr这个数组
        if(brr[0]===key){
            return brr[1]
        }
    }
}

export function removeCookie(key,path ='/'){
    setCookie(key,null,-1,path)
}